package com.kkb.controller.dianpugaikuang;

import com.kkb.bean.BillTable;
import com.kkb.bean.OrderTable;
import com.kkb.bean.User;
import com.kkb.service.dianpugaikuang.DianPuGaiKuangServcie;
import com.kkb.vo.BaseResp;
import com.kkb.vo.dianpugaikuang.SelectBillSReq;
import com.kkb.vo.dianpugaikuang.SelectDainPuGuanZhu;
import com.kkb.vo.dianpugaikuang.SelectOrderSReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author sufenglong
 * @date 2021/4/13 11:17
 * @describe:
 */
@RestController
public class DianPuGaiKuangController {


    @Autowired
    private DianPuGaiKuangServcie dianPuGaiKuangServcie;


    /**
     * 店铺关注数
     */
    @GetMapping("/selectGuanZhu")
    public BaseResp<Map<String, Object>> selectGuanZhu(SelectDainPuGuanZhu selectDainPuGuanZhu, HttpServletRequest request) {

       // User user = (User) request.getSession().getAttribute("user");

        try {
           // selectDainPuGuanZhu.setSId(user.getUserId());

            selectDainPuGuanZhu.setSId(2);
            Map<String, Object> map = dianPuGaiKuangServcie.selectGuanZhuBySid(selectDainPuGuanZhu);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000", false, "查询失败");
        }
    }


    /**
     * 今日订单量
     *
     * @param selectOrderSReq
     * @return
     */
    @GetMapping("/selectJOrder")
    public BaseResp<Map<String, Object>> selectJOrder(SelectOrderSReq selectOrderSReq, HttpServletRequest request) {

         //User user = (User) request.getSession().getAttribute("user");

        try {
            //User user = new User();
           // selectOrderSReq.setSellerId(user.getUserId());
            selectOrderSReq.setSellerId(2);
            Map<String, Object> map = dianPuGaiKuangServcie.selectJOrder(selectOrderSReq);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000", false, "查询失败");
        }
    }


    /**
     * 今日收入
     *
     * @param selectBillSReq
     * @return
     */
    @GetMapping("/selectJIncome")
    public BaseResp<Map<String, Object>> selectJIncome(SelectBillSReq selectBillSReq,HttpServletRequest request) {

        //User user = (User) request.getSession().getAttribute("user");

        try {
            Map<String, Object> map = dianPuGaiKuangServcie.selectJIncome(selectBillSReq);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000", false, "查询失败");
        }
    }


}
